import { http } from '@/utils/http'
import { groupInfo } from './model'

/** 查询群聊列表 */

export const getGroupList = () => {
  return http.get<any>('/edu/group/list')
}

/** 查询群聊详情 */

export const findGroupInfo = (groupId: string | number) => {
  return http.get<any>(`/edu/group/find/${groupId}`)
}

/** 发送群聊消息 */
export const groupSend = (data: groupInfo) => {
  return http({
    url: '/edu/message/group/send',
    method: 'POST',
    data,
  })
}

/** 修改群聊信息 */
export const updateGroup = (data: groupInfo) => {
  return http({
    url: '/edu/group/modify',
    method: 'PUT',
    data,
  })
}
/** 修改群名称 */
export const updateGroupName = (data: groupInfo) => {
  return http({
    url: '/edu/group/modify/name',
    method: 'POST',
    data,
  })
}

/** 邀请进群 */
export const inviteGroup = (data: groupInfo) => {
  return http({
    url: '/edu/group/invite',
    method: 'POST',
    data,
  })
}

/** 踢出群聊--- */
export const kickGroup = (data: groupInfo) => {
  return http({
    url: '/edu/group/kick',
    method: 'DELETE',
    data,
  })
}

/** 创建群聊 */
export const createGroup = (data: groupInfo) => {
  return http({
    url: '/edu/group/create',
    method: 'POST',
    data,
  })
}

/** 查询群聊成员 */

export const membersGroupInfo = (groupId: string | number) => {
  return http.get<any>(`/edu/group/members/${groupId}`)
}

/** 拉取离线消息 */

export const getPullOfflineMessage = (minId: string) => {
  return http.get<any>('/edu/message/group/pullOfflineMessage', { minId })
}
/** 解散群聊 */

export const deleteGroupInfo = (groupId: string | number) => {
  return http.delete<any>(`/edu/group/delete/${groupId}`)
}
